'use strict';
const dayjs = require("dayjs");
module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;
  const Config = app.model.define(
    'Config',
    {
      id: {type: INTEGER, primaryKey: true, autoIncrement: true},
      code: STRING,
      desc: STRING,
      value: STRING,
      create_time: {
        type: DATE,
        get() {
          return dayjs(this.getDataValue('create_time')).format('YYYY-MM-DD HH:mm:ss');
        }
      },
    },
    {
      tableName: 'config',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: 'updated_time', // 不想要 updatedAt
      createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );
  return Config
};
